package com.yzd.learnjava.enumerated;

import java.util.EmptyStackException;
import java.util.EnumMap;
import java.util.Map;

import com.yzd.learnjava.util.Print;

public class EnumMaps {
	public static void main(String[] args) {
		EnumMap<AlarmPoints, Command> em = new EnumMap<AlarmPoints, Command>(AlarmPoints.class);
		em.put(AlarmPoints.KITCHEN, new Command() {
			public void action() {
				Print.print("Kitchen fire");
			}
		});
		em.put(AlarmPoints.BATHROOM, new Command() {
			public void action() {
				Print.print("BATHROOM Alert");
			}
		});
		
		for(Map.Entry<AlarmPoints, Command> e : em.entrySet()) {
			Print.print(e.getKey() + " : " + e.getValue());
			e.getValue().action();
		}
		
		try {
			em.get(AlarmPoints.BTILITY).action();
		} catch (Exception e) {
			
		}
	}
}

interface Command{
	void action();
}
